﻿Namespace BaseballScoreKeeper.Core
    Public Class BaseballPlayer
#Region "Private Methods"
        Private _Name As Name
        Private _FieldPositions As List(Of BaseballFieldPosition)
        Private _BattingDirection As Handedness
        Private _ThrowingDirection As Handedness
#End Region

#Region "Public Methods"
#Region "Constructor(s)"
        Public Sub New()

        End Sub

        Public Sub New(ByVal copy As BaseballPlayer)

        End Sub

        Public Sub New(ByVal name As Name, ByVal fieldPositions As List(Of BaseballFieldPosition),
                       ByVal battingDirection As Handedness, ByVal throwingDirection As Handedness)
            Me._Name = New Name(name)
            Me._FieldPositions = New List(Of BaseballFieldPosition)(fieldPositions)
            Me._BattingDirection = battingDirection
            Me._ThrowingDirection = throwingDirection
        End Sub
#End Region

#Region "Object Methods"
        Public Function DoesPlayPosition(ByVal position As BaseballFieldPosition) As Boolean
            Return _FieldPositions.Contains(position)
        End Function
#End Region

#Region "Overridden Methods"
        Public Overrides Function Equals(ByVal obj As Object) As Boolean
            Dim isEqual As Boolean = False
            If obj.GetType() Is GetType(BaseballPlayer) Then
                Dim comparePlayer As BaseballPlayer = DirectCast(obj, BaseballPlayer)
                If ((Me.Name = comparePlayer.Name) AndAlso
                    (Me.BattingDirection = comparePlayer.BattingDirection) AndAlso
                    (Me.ThrowingDirection = comparePlayer.ThrowingDirection)) Then
                    isEqual = True
                End If
            Else
                isEqual = MyBase.Equals(obj)
            End If
            Return isEqual
        End Function

        Public Overrides Function GetHashCode() As Integer
            Return MyBase.GetHashCode()
        End Function
#End Region

#Region "Operators"
        Public Shared Operator =(ByVal player1 As BaseballPlayer, ByVal player2 As BaseballPlayer) As Boolean
            Dim areEqual As Boolean = False
            If ((player1.Name = player2.Name) AndAlso
                (player1.BattingDirection = player2.BattingDirection) AndAlso
                (player1.ThrowingDirection = player2.ThrowingDirection)) Then
                areEqual = True
            End If
            Return areEqual
        End Operator

        Public Shared Operator <>(ByVal player1 As BaseballPlayer, ByVal player2 As BaseballPlayer) As Boolean
            Return (Not (player1 = player2))
        End Operator
#End Region
#End Region

#Region "Properties"
        Public ReadOnly Property Name As Name
            Get
                Return _Name
            End Get
        End Property

        Public ReadOnly Property BattingDirection As Handedness
            Get
                Return _BattingDirection
            End Get
        End Property

        Public ReadOnly Property ThrowingDirection As Handedness
            Get
                Return _ThrowingDirection
            End Get
        End Property
#End Region
    End Class
End Namespace